import React, { useState, useEffect } from "react";
import { TodolistContext } from "./App";

const Input = ({ upDateList }) => {
    const [val, setVal] = useState("1234");
    return (
        <div>
            <input
                type="text"
                value={val}
                onChange={(e) => {
                    setVal(e.target.value); //里面传的是要传的值
                }}
            />
            {/* <button onClick={() => upDateList(val)}>添加</button> */}
            <TodolistContext.Consumer>
                {(state) => {
                    return <button onClick={() => state.upDateList(val)}>添加</button>;
                }}
            </TodolistContext.Consumer>
        </div>
    );
};
export default Input;
